import warshipPlaneDictJson from '@/public/json/warshipPlaneDictJson/data.json'
// import enemy_aircraft_1 from '@/public/json/mapJson/enemy_aircraft_1.json';
// import enemy_aircraft_2 from '@/public/json/mapJson/enemy_aircraft_2.json';
// import enemy_aircraft_3 from '@/public/json/mapJson/enemy_aircraft_3.json';
import our_militray_aircraft_1 from '@/public/json/mapJson/our_militray_aircraft_1.json'
import our_militray_aircraft_2 from '@/public/json/mapJson/our_militray_aircraft_2.json'
import our_militray_aircraft_3 from '@/public/json/mapJson/our_militray_aircraft_3.json'
import track1 from '@/public/json/mapJson/track1.json'
// import track2 from '@/public/json/mapJson/track2.json';
import track3 from '@/public/json/mapJson/track3.json'
import track4 from '@/public/json/mapJson/track4.json'

const planeData = renderObj('airplaneData')
const passengerPlaneData = renderObj('passengerPlaneData')
export function genUseData() {
  const useData = [
    //   {
    //   name: 'air1',
    //   data: exeAirPlaneData(enemy_aircraft_1),
    // },
    // {
    //   name: 'air2',
    //   data: exeAirPlaneData(enemy_aircraft_2),
    // },
    // {
    //   name: 'air3',
    //   data: exeAirPlaneData(enemy_aircraft_3),
    // },
    {
      name: 'air7',
      data: exeAirPlaneData(our_militray_aircraft_1)
    },
    {
      name: 'air8',
      data: exeAirPlaneData(our_militray_aircraft_2)
    },
    {
      name: 'air9',
      data: exeAirPlaneData(our_militray_aircraft_3)
    },
    {
      name: 'track1',
      data: exeAirPlaneData(track1)
    },
    // {
    //   name: 'track2',
    //   data: exeAirPlaneData(track2),
    // },
    {
      name: 'track3',
      data: exeAirPlaneData(track3)
    },
    {
      name: 'track4',
      data: exeAirPlaneData(track4)
    }
  ]
  return useData
}
// 处理飞机数据，组合成带详细信息的
function exeAirPlaneData(jsonData: any) {
  const { properties } = jsonData.features[0]
  const linkStr = `${properties.linkData}-${properties.linkId}`
  const propertiesData = planeData[linkStr] ?? passengerPlaneData[linkStr]
  jsonData.features[0].properties = {
    ...properties,
    ...propertiesData
  }
  return jsonData
}
//
// export function covertAirPlaneData() {
//   const airplaneData = renderObj('airplaneData');
//   console.log('airplaneData', airplaneData);
//   return airplaneData;
// }
// 形式: {key-id: value},生成所有飞机信息
function renderObj(key: string) {
  const tree = {}
  warshipPlaneDictJson[key].map((item) => {
    tree[`${key}-${item.id}`] = item
  })
  return tree
}
